/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
 * Description: Header for kasan
 * Author: Huawei OS Kernel Lab
 * Create: Tur Oct 19 17:57:08 2021
 */

#ifndef __MM_KASAN_KASAN_H
#define __MM_KASAN_KASAN_H

#include <linux/compiler.h>
#include <linux/kasan.h>

#define KASAN_POISON	0xFF
#define KASAN_UNPOISON	0
#define KASAN_SHADOW_SCALE_SIZE	8
#define KASAN_ALLOCA_REDZONE_SIZE	32

/* kasan global struct layout is defined by gcc */
struct kasan_global {
	const void *beg;                /* the begin addr of the global variable */
	size_t size;                    /* the global variable size. */
	size_t size_with_redzone;       /* the variable with red zone size. 32 bytes aligned */
	const void *name;               /* name of the variable */
	const void *mod_name;           /* name of the module that define the global variable */
	unsigned long has_dyn_init;     /* Non-zero if the global has dyn init only for C++ */
#if KASAN_ABI_VERSION >= 4
	struct kasan_source_location *loc; /* the location of the variable */
#endif
#if KASAN_ABI_VERSION >= 5
	char *odr_indtor;               /* the address of the ODR indicator symbol */
#endif
};

#endif
